#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(opcodes_dumper, [2.0.0], [https://github.com/laruence/opcodesdumper])
AM_INIT_AUTOMAKE

AC_CONFIG_SRCDIR([opcodes_dumper.c])
AC_CONFIG_HEADER([config.h])

AC_MSG_CHECKING(for php-config)
AC_ARG_WITH(php-config,
             [  --with-php-config=[DIR]  Path to php-config [php-config]], 
             [PHP_CONFIG=$withval],
             [])

if test -z "$PHP_CONFIG"
then
    PHP_CONFIG=`which php-config`
fi

if test ! -f $PHP_CONFIG 
then
    AC_MSG_ERROR([could not found php-config, use --with-php-config to set])
fi

AC_MSG_RESULT($PHP_CONFIG)

SAPIS=`$PHP_CONFIG --php-sapis 2>/dev/null | grep embed`

if test -z "$SAPIS"
then
    AC_MSG_ERROR([your php does not support embed sapi, please rebuild it with --enable-embed])
fi

PREFIX=`$PHP_CONFIG --prefix 2>/dev/null | sed -e 's/\/$//g' `
INCLUDES=`$PHP_CONFIG --includes 2>/dev/null | sed -e 's/\/$//g' `
LIBRARIES=$PREFIX"/lib"

CPPFLAGS=$INCLUDES
LDFLAGS="-Wl,-rpath,${LIBRARIES} -L${LIBRARIES}"
 
# Checks for libraries.
AC_MSG_CHECKING(for php5 library)
AC_CHECK_LIB([php5], [php_var_dump])

# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_OUTPUT([Makefile])
